<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    {% load static %}
    <script src="{% static 'js/jquery.min.js' %}"></script>
    <script src="{% static 'bootstrap-3.4.1-dist/js/bootstrap.min.js' %}"></script>
    <link href="{% static 'bootstrap-3.4.1-dist/css/bootstrap.min.css' %}" rel="stylesheet">
    <link href="{% static 'dist/sweetalert.css' %}" rel="stylesheet">
    <script src="{% static 'dist/sweetalert.min.js' %}"></script>
    <link href="{% static 'css/font-awesome.min.css' %}" rel="stylesheet">
    <link href="{% static 'css/dashboard.css' %}" rel="stylesheet">
</head>
<body>
<div class="container">
      <form class="form-signin col-md-offset-3" method="post">
        <h2 class="form-signin-heading col-md-offset-3">登录</h2>
        <label for="inputText" class="sr-only">用户名:</label>
        <input type="text" name="username" id="inputText" class="form-control" style="width: 500px;height: 50px" placeholder="Username" required autofocus>
          <br/>
        <label for="inputPassword" class="sr-only">密码:</label>
        <input type="password" name="password" id="inputPassword" class="form-control" style="width: 500px;height: 50px" placeholder="Password" required>
{#        <div class="checkbox">#}
{#          <label>#}
{#            <input type="checkbox" value="remember-me"> 记住我#}
{#          </label>#}
{#        </div>#}
          <br>
        <button class="btn btn-lg btn-primary btn-block" id="btnlog" style="width: 500px;height: 50px" type="submit">登录</button>
      </form>
    </div> <!-- /container -->
<script>
    $("#btnlog").click(function () {
        $.ajax({
            url:"",
            type:"post",
            data:{
                "username":$("#inputText").val(),
                "password":$("#inputPassword").val(),
            },
            success:function (e) {
                console.log(e);
                if(e.code===200){
                    swal("登录成功!", "", "success");
                    window.location.href='http://127.0.0.1:8000/tea_admin'+e.url;
                }else if(e.code===201){
                    swal(e.msg);
                    {#window.location.reload()#}
                }else {
                       swal(e.msg);
                    {#window.location.reload()#}
                }
            }
        })
    })
</script>
</body>
</html>